﻿@model ProductReviewsModel
@using Nop.Web.Models.Catalog;
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title
    Html.AddTitleParts(Model.ProductName);
    Html.AddTitleParts(T("PageTitle.ProductReviews").Text);
}



<div class="features_items product-details-review-page"><!--features_items-->
    <h2 class="title text-center">@T("Reviews.ProductReviewsFor") <a href="@Url.RouteUrl("Product", new { SeName = Model.ProductSeName })">@Model.ProductName</a></h2>

    
    <div class="product-details">
        <div class="custom-page-box-div">
            @if (Model.AddProductReview.SuccessfullyAdded)
            {
                <div class="result alert alert-success square-box">
                    @Model.AddProductReview.Result
                </div>
            }else
            {
                <div class="row">
                    <div class="col-sm-12 ">
                   
                        <p><b>@T("Reviews.Write")</b></p>
                        <div class="write-review" id="review-form">
                    
                            @using (Html.BeginForm())
                            {
                                <div class="message-error">@Html.ValidationSummary(true)</div>
                                <div class="form-fields">
                                    <div class="form-group row">
                                        @Html.LabelFor(model => model.AddProductReview.Title, new { @class = "col-md-2 control-label" }, ":")
                                        <div class="col-md-6">
                                            @Html.TextBoxFor(model => model.AddProductReview.Title, Model.AddProductReview.CanCurrentCustomerLeaveReview ? (object)(new { @class = "review-title gray-input" }) : (object)(new { @class = "review-title, form-control", disabled = "disabled" }))
                                        </div>
                                        <div class="col-md-4">
                                            @Html.ValidationMessageFor(model => model.AddProductReview.Title)
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        @Html.LabelFor(model => model.AddProductReview.ReviewText, new { @class = "col-md-2 control-label" }, ":")
                                        <div class="col-md-6">
                                            @Html.TextAreaFor(model => model.AddProductReview.ReviewText, Model.AddProductReview.CanCurrentCustomerLeaveReview ? (object)(new { @class = "review-text gray-textarea", rows="7" }) : (object)(new { @class = "review-text, form-control", disabled = "disabled", rows="7" }))
                                        </div>
                                        <div class="col-md-4">
                                            @Html.ValidationMessageFor(model => model.AddProductReview.ReviewText)
                                        </div>
                                    </div>
                                    <div class="review-rating form-group row">
                                        @Html.LabelFor(model => model.AddProductReview.Rating, new { @class = "col-md-2 control-label" }, ":")
                                        <div class="col-md-8">
                                            <strong>@T("Reviews.Fields.Rating.Bad")</strong>
                                    
                                            @Html.RadioButtonFor(model => model.AddProductReview.Rating, "1", new { id = "addproductrating_1" })
                                            @Html.RadioButtonFor(model => model.AddProductReview.Rating, "2", new { id = "addproductrating_2" })
                                            @Html.RadioButtonFor(model => model.AddProductReview.Rating, "3", new { id = "addproductrating_3" })
                                            @Html.RadioButtonFor(model => model.AddProductReview.Rating, "4", new { id = "addproductrating_4" })
                                            @Html.RadioButtonFor(model => model.AddProductReview.Rating, "5", new { id = "addproductrating_5" })
                                    
                                            <strong>@T("Reviews.Fields.Rating.Excellent")</strong>
                                        </div>
                                    </div>
                                    @if (Model.AddProductReview.DisplayCaptcha)
                                    {
                                        <div class="captcha-box form-group row">
                                            <div class="col-md-6">
                                                @Html.Raw(Html.GenerateCaptcha())
                                            </div>
                                        </div>
                                    }
                                </div>
                                <div class="form-group row">
                                    <div class="col-md-2 pull-right">
                                        <div class="buttons">
                                            <input type="submit" name="add-review" class="button-1 btn btn-primary write-product-review-button btn btn-default" value="@T("Reviews.SubmitButton")" />
                                        </div>
                                    </div>
                                </div>
                            }
                        </div>
				
                    
                    </div>
                </div>

                
            }
            
        </div>
        
    </div>
</div>


@if (Model.Items.Count > 0)
            {
               
                
           

                <div class="features_items product-details-review-page"><!--features_items-->
                    <h2 class="title text-center">@T("Reviews.ExistingReviews")</h2>

    
                    <div class="product-details">
                        <div class="custom-page-box-div">
                            
                                
                                    
                                    @foreach (var review in Model.Items)
                                    {
                                        int ratingPercent = review.Rating * 20;



                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="blog-post-area">
                                                    <div class="single-blog-post">
                                                        <h3>@review.Title</h3>
                                                        <div class="post-meta">
                                                            <ul>
                                                                <li><i class="fa fa-user"></i> 
                                                                    @if (review.AllowViewingProfiles)
                                                                    {
                                                                        <a href="@Url.RouteUrl("CustomerProfile", new { id = review.CustomerId })">@(review.CustomerName)</a>
                                                                    }
                                                                    else
                                                                    {
                                                                        @review.CustomerName
                                                                    }
                                                                </li>
                                                                @*<li><i class="fa fa-clock-o"></i> 1:33 pm</li>*@
                                                                <li><i class="fa fa-calendar"></i> @review.WrittenOnStr</li>
                                                            </ul>
                                                            <span>
                                                                <div class="product-review-box">
                                                                    <div class="rating ">
                                                                        <div style="width: @(ratingPercent)%">
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </span>

                                                        </div>
    
                                                        <p>@Html.Raw(Nop.Core.Html.HtmlHelper.FormatText(review.ReviewText, false, true, false, false, false, false))</p>
                                                        
                                                    </div>
                                                </div>

                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-12">
                                                @Html.Partial("_ProductReviewHelpfulness", review.Helpfulness, new ViewDataDictionary())
                                            </div>
                                        </div>



                                    }
                                </div>
                                

                            </div>
                            
                        </div>
                   
                



 }


